﻿using UnityEngine;
using System.Collections;

public class UIConnectionWaiting : MonoBehaviour
{
    private static UIConnectionWaiting instance;

    public static UIConnectionWaiting Instance
    { get { return instance; } }

    void Awake()
    {
        instance = this;
        DontDestroyOnLoad(this);
        Hide();
    }
    public void Show(string s = "")
    {
#if DEBUG
        Debuger.Log("cc: Show Wait " + s);
#endif
        gameObject.SetActive(true);
        StartCoroutine(_Hide());
    }
    public void Hide(string s = "")
    {
        #if DEBUG
        Debuger.Log("cc: Hide Wait " + s);
#endif
        StopAllCoroutines();
        gameObject.SetActive(false);
    }
    /// <summary>
    /// 15秒后自动隐藏转圈等待并弹出掉线框
    /// </summary>
    /// <returns></returns>
    IEnumerator _Hide()
    {
        yield return new WaitForSeconds(15);
        if (gameObject.activeSelf)
        {
            //NetConnection.g_pInstance.ForceConnectionException();
            Hide("_Hide");
        }

    }
}
